package com.maslyk.invitation.entitybean;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import com.maslyk.invitation.audit.ObjectName;
import com.maslyk.invitation.audit.PropertyLabel;
import com.maslyk.invitation.entitybean.abstrct.GenericEntity;

/**
 *
 * @author kris
 */
@Entity
@Table(name = "text")
@ObjectName(label="tekst")
public class Text implements GenericEntity
{
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @Column(name = "content")
    @PropertyLabel(label="Treść")
    private String content;
    @Column(name = "type")
    private Integer type;
    @Column(name = "code")
    @PropertyLabel(label="Kod")
    private String code;
    @Column(name = "description")
    private String description;

    public Text()
    {
    }

    public Text(Integer id)
    {
        this.id = id;
    }

    public Text(Integer id, String content)
    {
        this.id = id;
        this.content = content;
    }

    public Integer getId()
    {
        return id;
    }

    public void setId(Integer id)
    {
        this.id = id;
    }

    public String getContent()
    {
        return content;
    }

    public void setContent(String content)
    {
        this.content = content;
    }

    public Integer getType()
    {
        return type;
    }

    public void setType(Integer type)
    {
        this.type = type;
    }
    
    public String getCode()
    {
        return code;
    }

    public void setCode(String code)
    {
        this.code = code;
    }
    public String getDescription()
    {
        return description;
    }

    public void setDescription(String description)
    {
        this.description = description;
    }

    @Override
    public int hashCode()
    {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object)
    {
        if (!(object instanceof Text))
        {
            return false;
        }
        Text text  = (Text) object;
        return (this.code.equals(text.getCode()) && this.type.equals(text.getType()));
    }

    @Override
    public String toString()
    {
        return this.code+"/"+this.type;
    }
    
    public static String getBeanName()
    {
    	return "textBean";
    }

	public String getKey() {
		return String.valueOf(id);
	}

	@Override
	protected Object clone() throws CloneNotSupportedException {
		Text t = (Text) super.clone();
		t.setId(null);
		return t;
	}
	
	public boolean isInserted() {
		return id != null;
	}
}
